import java.util.HashMap;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Session;

import jpa.entities.ClientBestelling;

import org.apache.activemq.ActiveMQConnectionFactory;


public class Bestel {
	public void bestel(int id, HashMap<Integer,String> producten) throws Exception
	{
	    String url = "tcp://WIN-D1OIUKBK3UL:61616";

	    // Name of the queue we will be sending messages to
	    String subject = "incoming.esb";
		
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
        Connection connection = connectionFactory.createConnection();
        connection.start();
        
        Session session = connection.createSession(false,  Session.AUTO_ACKNOWLEDGE);

        Destination destination = session.createQueue(subject);

        MessageProducer producer = session.createProducer(destination);
	    
	    
		ClientBestelling pk = new ClientBestelling();
        pk.setAantal(1);
        pk.setKlantId(2);
        pk.setProductId(id);
        pk.setProductSoort(producten.get(id));
        
        ObjectMessage message = session.createObjectMessage(pk);
        
        producer.send(message);
        
        System.out.println("Bestelling voltooid");
	}
}
